from django.db import models
from apps.common.base.models import BaseModel
from  apps.system.user.models import User
import django.utils.timezone as timezone
from apps.system.lessee.models import Lessee

class Learn(BaseModel):

    lessee = models.ForeignKey(Lessee, related_name="lessee_learn", verbose_name='租户',
                               on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    user=models.ForeignKey(User, related_name='user_learn', verbose_name='所属用户', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    users = models.ManyToManyField(User, related_name='users_learn', blank=True, default=[], db_constraint=False)
    name = models.CharField("名称", max_length=200, blank=True, null=True, default='')
    longText = models.TextField("长文本", max_length=10000, null=True, blank=True, default='')
    isShow = models.BooleanField('是否显示', default=0)
    count = models.IntegerField("数量", default=0)
    price = models.DecimalField("价格", max_digits=10, decimal_places=2, default=0)
    status = models.IntegerField("状态", blank=True, null=True, default=0)  # 1：正常 2: 异常
    startTime = models.DateTimeField('开始时间', blank=True, null=True, default=timezone.now)
    

    class Meta:
        verbose_name = 'Learn'
        verbose_name_plural = verbose_name